﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Data;

namespace QuanLyKho
{
    public partial class frmDangNhap : Form
    {
        private TaiKhoan taiKhoan;
        public frmDangNhap()
        {
            InitializeComponent();
        }

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            taiKhoan = new TaiKhoan(txtTenTaiKhoan.Text.Trim(), txtMatKhau.Text.Trim());

            if (connection.open(taiKhoan) == "OK")
            {
                frmQuanLyKho frmWHM = new frmQuanLyKho();
                Hide();
                frmWHM.ShowDialog();
                Close();
            }
            else
                MessageBox.Show("Tài khoản hoặc mật khẩu sai", "Thông báo");
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void thayDoiChu(object sender, EventArgs e)
        {
            if (txtTenTaiKhoan.Text.Trim() != "" && txtMatKhau.Text.Trim() != "")
                btnDangNhap.Enabled = true;
            else
                btnDangNhap.Enabled = false;
        }
    }
}
